import react from 'react';
import axios from 'axios';

async function getData(file_name) {
  console.log(file_name);
  try {
    const data = new FormData();
    data.append('file_name', file_name);
    const response = await axios({
      headers: {
        'Content-Type': 'application/json'
      },
      method: 'post',
      url: 'http://127.0.0.1:5000/download',
      data: data,
    });
    if (response && response.status === 200) {
      return response.data;
    } else {
      return 'error';
    }
  } catch (error) {
    console.error('Error:', error);
    return 'error';
  }
}

export default getData;
